﻿@using ContentCreator.Fields
@using ContentCreator.Fields
@using Orchard.ContentManagement
@using Orchard.Utility.Extensions;

@{
    var field = (ContentCreatorField)Model.ContentField;
    string name = field.DisplayName;
    var contentItems = field.ContentItems;
}
<p class="content-creator-field content-creator-field-@name.HtmlClassify()">
    <span class="name">@name:</span>

    @{
        //Avoid problems of enumerating to many times;
        var enumerable = contentItems as IList<ContentItem> ?? contentItems.ToList();

        if (enumerable.Any())
        {
            foreach (var contentItem in enumerable)
            {
        <span class="value">@Html.ItemDisplayLink(contentItem)</span>
                if (contentItem != enumerable.Last())
                {
        <span>,</span>
                }
            }
        }
        else
        {
        <span class="value">@T("No content items.")</span>
        }
    }
</p>
